<form method="post" action="{$base_url}&action=prp_save">
	<table class="list prp">
		{foreach $structure as $name => $field}
			<tr>
				<td{if $field['type'] == "separator"} style="padding-top: 20px; border-bottom-width: 10px" colspan="2"{/if}>
						{if $field['type'] != "radio"}<label for="config_{$name}">{/if}
							<strong>{$field['label']}</strong>
							{if !empty($field['description'])}<div class="description">{$field['description']}</div>{/if}
						{if $field['type'] != "radio"}</label>{/if}
				</td>
				{if $field['type'] != "separator"}
					<td>
						{if $field['type'] == "select"}
						
							<select id="config_{$name}" name="config[{$name}]{if $field['multiselect']}[]" multiple size="{$field['multiselect']}{/if}">
								{foreach $field['values'] as $value => $label}
									{if is_array($label)}
										<optgroup label="{$value}">
											{foreach $label as $_v => $_l}
												<option{if (isset($field['dvalues']) && is_array($field['dvalues']) && in_array($_v, $field['dvalues'])) || (isset($field['dvalues']) && $field['dvalues'] == $_v) || (isset($data[$name]) && is_array($data[$name]) && in_array($_v, $data[$name])) || (isset($data[$name]) && $data[$name] == $_v)} selected{/if} value="{$_v}">{$_l}</option>
											{/foreach}
										</optgroup>
									{else}
										<option{if (isset($field['dvalues']) && is_array($field['dvalues']) && in_array($value, $field['dvalues'])) || (isset($field['dvalues']) && $field['dvalues'] == $value) || (isset($data[$name]) && is_array($data[$name]) && in_array($value, $data[$name])) || (isset($data[$name]) && $data[$name] == $value)} selected{/if} value="{$value}">{$label}</option>
									{/if}
								{/foreach}
							</select>
						
						{elseif $field['type'] == "text"}
						
							<input id="config_{$name}" type="text" value="{if isset($data[$name]) && empty($data[$name])}{elseif !empty($data[$name])}{$data[$name]}{elseif !empty($field['dvalue'])}{$field['dvalue']}{/if}" name="config[{$name}]" />
							
						{elseif $field['type'] == "checkbox"}
							
							<input id="config_{$name}" type="checkbox" value="1" name="config[{$name}]"{if (isset($data[$name]) && $data[$name] == 1) || (isset($field['dvalue']) &&  $field['dvalue'] == 1)} checked{/if}/>

						{elseif $field['type'] == "separator"}

							<input id="config_{$name}" type="checkbox" value="1" name="config[{$name}]"{if (isset($data[$name]) && $data[$name] == 1) || (isset($field['dvalue']) &&  $field['dvalue'] == 1)} checked{/if}/>
							
						{elseif $field['type'] == "radio"}
							
							{foreach $field['values'] as $_v => $_l}
								<label for="config_{$name}_{$_v}">
									<input id="config_{$name}_{$_v}" type="radio" name="config[{$name}]" value="{$_v}"{if (isset($data[$name]) && $data[$name] == $_v) || (isset($field['dvalues']) && $field['dvalues'] == $_v)} checked{/if}/>
									{$_l}
								</label>
							{/foreach}

						{/if}
					</td>
				{/if}
			</tr>
		{/foreach}
	</table>
	<div class="buttons">
		<input type="submit" class="save" value="Сохранить" />
		<input type="reset" class="cancel" value="Отменить" onclick="history.go(-1)"/>
	</div>
</form>